package ctype

import "encoding/json"

type Role int //权限
const (
	PermissionAdmin        Role = 1 //管理员
	PermissionUser         Role = 2 //普通用户
	PermissionVisitor      Role = 3 //游客
	PermissionDisabledUser Role = 4 //禁用用户

)

func (s Role) MarshalJSON() ([]byte, error) {
	return json.Marshal(s.String())
}

func (s Role) String() string {
	var str string
	switch s {
	case PermissionAdmin:
		str = "管理员"
	case PermissionUser:
		str = "普通用户"
	case PermissionVisitor:
		str = "游客"
	case PermissionDisabledUser:
		str = "禁用用户"
	default:
		str = "未知"
	}
	return str
}
